import { useState,useEffect } from 'react'
import logo from './logo.svg'
import './App.css'
import Detail from './Detail'
import User from './User'
import Home from './Home'
import {Routes,Route,Link, useNavigate} from 'react-router-dom'
function App() {
  const navigate = useNavigate();

  useEffect( () => {
    setTimeout(() => {
      // js 跳转  BOM 原始
      // history.pushState(null,null,'/post/7086019601372282888')
      // window.location.href = '/post/7086019601372282888'
      navigate('/post/7086019601372282888')
    }, 2000);
  },[])

  return (
    <div className="App">
       {/* 路由的配置 */}
     <nav>
       <Link to ="/post?id=7086019601372282889">文章</Link>
       <Link to ="/post/7086019601372282888">文章</Link>
       <Link to ="/user">用户</Link>
    
     </nav>
     <Routes>
       {/* 关于
       页面
       详情页 */}
      <Route path="/" element={<Home/>}/>
      <Route path="/post" element={<Detail/>}/>
      <Route path="/post/:id" element={<Detail/>}/>
      <Route path="/user" element={<User/>}/>
     </Routes>
    </div>
  )
}

export default App
